﻿@page "/todo"
@rendermode InteractiveServer

<h3>Todo</h3>

<ul>
    @foreach (var item in _todos)
    {
        <li>@item.Title</li>
    }
</ul>

<input @bind="_text"/>
<button class="btn btn-primary" @onclick="AddTodo">添加</button>

@code {
    private readonly List<TodoItem> _todos = [];

    private string _text = string.Empty;
    
    void AddTodo()
    {
        if (string.IsNullOrWhiteSpace(_text)) return;
        _todos.Add(new() { Title = _text });
        _text = string.Empty;
    }

}
